//
//  ApplicationHeader.swift
//  QualityControlSystem
//
//  Created by dundun on 17/1/19.
//  Copyright © 2017年 com.mask. All rights reserved.
//

import UIKit

class ApplicationHeader: UITableViewHeaderFooterView {
    
    var headerTitle: UILabel?
    var headerRightBtn: UIImageView?
    var headerClickedBlock: ( () -> Void)?
    
    
    override init(reuseIdentifier: String?) {
        super.init(reuseIdentifier: reuseIdentifier)
        contentView.backgroundColor = UIColor.white
        setupHeader()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupHeader() {
        headerTitle = UILabel()
        headerTitle?.textColor = Color.textMedium
        headerTitle?.font = UIFont.systemFont(ofSize: 16)
        headerTitle?.textAlignment = .left
        contentView.addSubview(headerTitle!)
        headerTitle?.snp.makeConstraints({ (make) in
            make.left.equalTo(self).offset(Padding.left)
            make.width.height.equalTo(100)
            make.centerY.equalTo(self)
        })
        
        headerRightBtn = UIImageView()
        headerRightBtn?.backgroundColor = UIColor.blue
//        headerRightBtn?.image = UIImage(named: "")
        contentView.addSubview(headerRightBtn!)
        headerRightBtn?.snp.makeConstraints({ (make) in
            make.right.equalTo(self).offset(-Padding.left)
            make.centerY.equalTo(self)
            make.size.equalTo(CGSize(width: 25, height: 25))
        })
        
        let tap = UITapGestureRecognizer(target: self, action: #selector(headerClicked(tap:)))
        contentView.addGestureRecognizer(tap)
    }
    
    func headerClicked(tap: UITapGestureRecognizer) {
        headerClickedBlock!()
    }

}
